home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
reader21.arc
/
R21.PAS
next >
Wrap
Pascal/Delphi Source File
|
1986-06-11
|
13KB
|
363 lines
program reader_21;
{Herein resides the source code and various comments for READER.COM.
READER 2.1 is used to view PC Gazette issue 1.03 and later.
Code written by Robert Flores...PC Gazette, 155 East C St. Suite D,
Upland, CA 91786}
type
strtype = string[15];
viewscreen = array[1..4096] of byte;
graftype = array[1..16384] of byte;
filelabel = string[12];
str80 = string[80];
yesansi = boolean;
var
i,j,x,y,
curpage,
lastpage,
curpart,
lastpart,
maxparts,
code,
slidepages,
i1,j1,i2,j2 : integer;
file2 : text;
filename2 : strtype;
filename,
grafile2,
ansifile,
bwansifile : array[1..6] of filelabel;
grafile : array[0..6] of filelabel;
ansipage,
grafpage,
grafpage2,
maxpages : array[1..6] of integer;
slide : array[1..13] of filelabel;
yesani : array[0..9] of boolean;
pluscolor,
ok,mono : boolean;
fileline : strtype;
ansimove : str80;
crtmode : byte absolute $0040:$0049;
scrncolor : array[0..9] of viewscreen;
file1 : file;
getchar : char;
storescreen : graftype;
screen0 : viewscreen absolute $b800:-7;
screen1 : viewscreen absolute $b000:-7;
grafscreen : graftype absolute $b800:-7;
procedure getparm; {Find out if there is any parameters on the command line}
var parms: strtype absolute cseg:$80;
s:strtype;
begin
s:='';
while (length(parms)>0) and (parms[1]=' ') do delete(parms,1,1);
while (length(parms)>0) and (parms[1]<>' ') do begin
s:=s+parms[1];delete(parms,1,1);
end;
filename2:=s;
end;
procedure showansi(aifile:filelabel); {Put ANSI animation on screen}
type regpack=record
case integer of
1 : (AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : INTEGER);
2 : (AL,AH,BL,BH,CL,CH,DL,DH : BYTE);
end;
var regs : regpack;
afile : text;
begin
assign(afile,aifile);
{$i-} reset(afile) {$i+};
ok:=(ioresult=0);
if ok then begin
readln(afile,ansimove);
val(copy(ansimove,6,4),i1,code);
for i:=1 to i1 do begin
readln(afile,ansimove);
for j:=1 to length(ansimove) do begin
with regs do begin
AH:=$02;
DL:=ord(copy(ansimove,j,1));
msdos(regs);
end;
end;
end;
close(afile);
end;
end;
procedure bottomline; {Put standard blurb on bottomline}
begin
if mono=true then gotoxy(12,25)
else begin
if (grafpage[curpart]=curpage) or (grafpage2[curpart]=curpage) then
begin
gotoxy(42,24);
textcolor(white);
write(' Press Space Bar for Hi-Res Display ');
end;
gotoxy(6,25);
end;
if pluscolor then textcolor(red) else textcolor(15);
write('Quit:F1 Pages:PgUp,PgDn,Home,End,& 0..',maxpages[curpart],'. Sections:A..',chr(maxparts+64),'.');
if mono=false then write(' Gallery:G.');
if (ansipage[curpart]=curpage) and (yesani[curpage]=false) then
begin
if pluscolor then showansi(ansifile[curpart]) else showansi(bwansifile[curpart]);
yesani[curpage]:=true;
if mono=true then scrncolor[curpage]:=screen1 else scrncolor[curpage]:=screen0;
end;
end;
procedure LoadScreen(gfile : filelabel); {Display a hires screen}
begin
hires;
Assign(File1,gfile);
{$I-} Reset(File1) {$I+};
ok:=(IOresult=0);
if ok then begin
blockread(File1,storescreen,128);
close (File1);
move(storescreen,grafscreen,16384);
end;
gotoxy(28,25);
write('Press any key to continue.');
gotoxy(1,1);
read(kbd,getchar);
textmode(c80);
if mono=true then screen1:=scrncolor[curpage] else screen0:=scrncolor[curpage];
bottomline;
end;
procedure Gallery; {Display all hires screens}
label quitslide1,quitslide2;
begin
i:=1;
hires;
gotoxy(1,3);
writeln(' PC Gazette Gallery');
gotoxy(1,15);
writeln(' A collection of PC Graphics for your enjoyment.');
repeat
Assign(file1,slide[i]);
{$i-} Reset(file1) {$i+};
ok:=(ioresult=0);
if not ok then begin
writeln(#7,#7,slide[i],' not found! Press a key to return to PC Gazette.');
read(kbd,getchar);
goto quitslide1;
end
else begin
blockread(file1,storescreen,128);
close(file1);
gotoxy(19,25);
write('Press any key to continue...Esc to exit.');
read(kbd,getchar);
if getchar=#27 then goto quitslide2;
move(storescreen,grafscreen,16384);
end;
i:=i+1;
until i>slidepages;
quitslide1 : gotoxy(19,25);
write('Press any key to continue...Esc to exit.');
read(kbd,getchar);
quitslide2 : delay(2);
textmode(c80);
if mono=true then screen1:=scrncolor[curpage] else screen0:=scrncolor[curpage];
bottomline;
end;
procedure getpart; {Load into memory a section of pages}
begin
for i:=0 to 9 do yesani[i]:=false;
assign(file1,filename[curpart]);
{$i-} reset(file1) {$I+};
ok:=(ioresult=0);
if not ok then begin
writeln(filename[curpart],' not found.');
halt;
end;
clrscr;
gotoxy(1,5);
write('Setting up Section ',chr(curpart+64),' into memory');
gotoxy(1,25);
for j:=0 to maxpages[curpart] do begin
blockread(file1,scrncolor[j],32);
end;
close(file1);
if not pluscolor then begin {put color stripping here}
for j:=0 to maxpages[curpart] do begin
i:=seg(scrncolor[j]);i2:=ofs(scrncolor[j]);i2:=i2+8;j2:=0;
repeat
mem[i:i2+j2]:=112;j2:=j2+2;
until j2>3840;
end;
end;
if crtmode=7 then screen1:=scrncolor[0] else screen0:=scrncolor[0];
curpage:=0;lastpage:=0;
bottomline;
if (mono=false) and (grafpage[curpart]=curpage) then loadscreen(grafile[curpart]);
if (mono=false) and (grafpage2[curpart]=curpage) then loadscreen(grafile2[curpart]);
end;
procedure startoff; {Find out what files will be used}
var ifile : filelabel;
begin
curpage:=0;lastpage:=0;curpart:=1;lastpart:=1;slidepages:=0;ifile:='reader.opt';
getparm;
if length(filename2)>0 then ifile:='reader.'+copy(filename2,1,3) else ifile:='reader.opt';
{ writeln(ifile);
read(kbd,getchar);}
assign(file2,ifile);
{$i-} reset(file2) {$i+};
ok:=(ioresult=0);
if not ok then begin writeln(ifile,' not found.');halt end
else begin
readln(file2,maxparts);
readln(file2,grafile[0]);
if (grafile[0]<>'<none>') and (mono=false) then loadscreen(grafile[0]);
for i:=1 to maxparts do begin
readln(file2,filename[i]);
readln(file2,maxpages[i]);
readln(file2,grafile[i]);
readln(file2,grafpage[i]);
readln(file2,grafile2[i]);
readln(file2,grafpage2[i]);
readln(file2,ansifile[i]);
readln(file2,bwansifile[i]);
readln(file2,ansipage[i]);
end;
readln(file2,slidepages);
if slidepages>0 then for i:=1 to slidepages do readln(file2,slide[i]);
end;
close(file2);
end;
Function getkey(var functionkey : boolean):char; {check keypress & see if it is a function key}
var ch : char;
begin
read(kbd,ch);
if (ch=#27) and keypressed then begin
read(kbd,ch);
functionkey:=true;
end
else functionkey:=false;
getkey:=ch;
end;
procedure movepage; {Determine what do do with keypress and execute}
var
inkey:char;
functionkey:boolean;
procedure pagemove(inkey:char; functionkey:boolean);
procedure dofunctioncommand(functkey:char);
begin
case functkey of
#71 : curpage:=0;
#79 : curpage:=maxpages[curpart];
#73 : curpage:=curpage-1;
#81 : curpage:=curpage+1;
#59 : begin
clrscr;
halt;
end;
end;
end;
begin
if functionkey then dofunctioncommand(inkey)
else
case upcase(inkey) of
'0'..'9': val(inkey,curpage,code);
'A'..'F': begin
case upcase(inkey) of
'A' : curpart:=1;
'B' : if maxparts>1 then curpart:=2;
'C' : if maxparts>2 then curpart:=3;
'D' : if maxparts>3 then curpart:=4;
'E' : if maxparts>4 then curpart:=5;
'F' : if maxparts>5 then curpart:=6;
end;
getpart;
end;
'G' : if (mono=false) and (slidepages>0) then gallery;
#32 : begin
if (mono=false) and (grafpage[curpart]=curpage) then loadscreen(grafile[curpart]);
if (mono=false) and (grafpage2[curpart]=curpage) then loadscreen(grafile2[curpart]);
end;
end;
end;
procedure increment;
begin
if curpage>maxpages[curpart] then curpage:=maxpages[curpart];
if curpage<0 then curpage:=0;
if curpage<>lastpage then begin
if crtmode=7 then screen1:=scrncolor[curpage] else screen0:=scrncolor[curpage];
bottomline;
end;
lastpage:=curpage;
end;
begin
repeat
inkey:=getkey(functionkey);
pagemove(inkey,functionkey);
increment;
until upcase(inkey) in [#10,^C,#59];
end;
begin
for j:=0 to 9 do yesani[j]:=false;
if crtmode=7 then mono:=true else mono:=false; {mono or color card?}
clrscr;
if mono=true then scrncolor[0]:=screen1 else scrncolor[0]:=screen0; {put page at right address}
yesani[0]:=true;
startoff;
clrscr;
textcolor(15);
textbackground(black);
writeln(' Aaron A. Aardvark and the Platypus Patrol present');
writeln;
writeln('═══════════════════════════════════════════════════════════════════════════════');
writeln(' ░░░░░▄░░░░░▄ ░░░░░▄░░░░░▄░░░░░▄░░░░░▄░░░░░▄░░░░░▄░░░░░▄');
writeln(' ░░░█░█░░░█▀▀ ░░░█▀▀░░░█░█ ▀░░░█░░░█▀▀ ░░░█▀ ░░░█▀░░░█▀▀ The');
writeln(' ░░░█░█░░░█ ░░░█░▄░░░█░█ ░░░█▀░░░░░▄ ░░░█ ░░░█ ░░░░░▄ Electronic');
writeln(' ░░░░░█░░░█ ░░░█░█░░░░░█░░░█▀ ░░░█▀▀ ░░░█ ░░░█ ░░░█▀▀ Journal');
writeln(' ░░░█▀▀░░░░░▄ ░░░░░█░░░█░█░░░░░▄░░░░░▄ ░░░█ ░░░█ ░░░░░▄');
writeln(' ▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀ ▀ ▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀▀▀');
writeln('═══════════════════════════════════════════════════════════════════════════════');
WRITELN;
writeln(' created by Robert Flores');
writeln(' Copyright 1986 Robert Flores` PC Gazette');
writeln;
writeln(' A User-supported Newsletter');
writeln;
writeln(' Reader version 2.1');
gotoxy(1,25);
if mono=true then begin
pluscolor:=false;
write(' Press any key to begin.');
read(kbd,getchar);
end
else begin
write(' Do you want this in color? (Y/N)');
read(kbd,getchar);
if upcase(getchar)='Y' then pluscolor:=true else pluscolor:=false;
end;
CLRSCR;
getpart;
movepage;
end. {That's all, folks!! R.F}